<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="domain.User" %>
<%@ include file="time.jsp" %>
<%@ page import="java.util.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script type="text/javascript" src="js/jquery.js"></script>
    <title>修改密码</title>
    <script type="text/javascript">
        $(function () {
            if ($("#changePasswordResult").length > 0) {
                alert($("#changePasswordResult").text());
            }
        });
    </script>
</head>
<body style="text-align:center;">
<%

    Object obj = session.getAttribute("user");
    User user = (User) obj;
    if (null == obj) {
%>
您尚未登陆，请登录！
<a href="login.jsp" name="login">去登录</a>
<a href="register.jsp" name="register">跳转注册</a>
<%
} else {
%>
<div style="text-align:center">
    当前用户:<%=user.getUsername() %>
    <a href="exit.jsp" name="exit">退出登录</a>
    <a href="login_success.jsp" name="success">返回</a><br>
    <h1>修改密码</h1>
</div>
<form action="UpdateInfoServlet" method="post">
    <input type="hidden" name="username" value=<%=user.getUsername() %>>
    <table align="center">
        <tr>
            <td>旧密码：</td>
            <td><input type="password" id="oldPassword" name="oldPassword"></td>
        </tr>
        <tr>
            <td>新密码：</td>
            <td><input type="password" id="newPassword" name="newPassword"></td>
        </tr>
    </table>
    <table align="center" cellspacing="12">
        <tr>
            <td align="left"><input type="submit" value="提交"></td>
            <td align="left"><a href="exit.jsp" name="exit2">退出登陆</a></td>
        </tr>
    </table>
</form>

<%
    Object result = request.getAttribute("changePasswordResult");
    if (result != null) {
%>
<div style="text-align:center">
    <br/>
    <h2><%=(String) result%>
    </h2>
</div>
<%
    }
%>
<%}%>
</body>
</html>